{
 "metadata": {
  "name": "ex_generic_scpi"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "InstrumentKit Library Examples"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Generic SCPI Instrument"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "In this example, we will demonstrate how to connect to a generic SCPI \n",
      "instrument and query its identification information."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We start by importing the InstrumentKit package."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import instruments as ik"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Next, we open our connection to the instrument. Here we use the generic \n",
      "SCPIInstrument class and open the connection using the Galvant Industries'\n",
      "GPIBUSB adapter. Our connection is made to the virtual serial port located at\n",
      "/dev/ttyUSB0 and GPIB address 1"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The connection method used will have to be changed to match your setup."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "inst = ik.generic_scpi.SCPIInstrument.open_gpibusb('/dev/ttyUSB0', 1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now that we are connected to the instrument, we can query its identification\n",
      "information. We will do this by using the SCPIInstrument property 'name'."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "print inst.name"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}